import request from '@/config/axios'

export interface BannerVO {
  id: number
  title: string
  description?: string
  imageUrl: string
  linkUrl?: string
  linkType: string
  sortOrder: number
  status: boolean
  startTime?: string
  endTime?: string
  clickCount: number
  createTime: string
  updateTime: string
}

export interface BannerPageReqVO extends PageParam {
  title?: string
  status?: boolean
  linkType?: string
  createTime?: string[]
}

export interface BannerCreateReqVO {
  title: string
  description?: string
  imageUrl: string
  linkUrl?: string
  linkType: string
  sortOrder: number
  status: boolean
  startTime?: string
  endTime?: string
}

export interface BannerUpdateReqVO extends BannerCreateReqVO {
  id: number
}

export interface BannerExportReqVO {
  title?: string
  status?: boolean
  linkType?: string
  createTime?: string[]
}

// 查询横幅管理分页
export const getBannerPage = (params: BannerPageReqVO) => {
  return request.get({ url: '/reading/admin/banners/page', params })
}

// 查询横幅管理详情
export const getBanner = (id: number) => {
  return request.get({ url: '/reading/admin/banners/get?id=' + id })
}

// 新增横幅管理
export const createBanner = (data: BannerCreateReqVO) => {
  return request.post({ url: '/reading/admin/banners/create', data })
}

// 修改横幅管理
export const updateBanner = (data: BannerUpdateReqVO) => {
  return request.put({ url: '/reading/admin/banners/update', data })
}

// 删除横幅管理
export const deleteBanner = (id: number) => {
  return request.delete({ url: '/reading/admin/banners/delete?id=' + id })
}

// 导出横幅管理 Excel
export const exportBanner = (params: BannerExportReqVO) => {
  return request.download({ url: '/reading/admin/banners/export-excel', params })
}

// 批量更新横幅状态
export const updateBannerStatusBatch = (data: { ids: number[]; status: boolean }) => {
  return request.put({ url: '/reading/admin/banners/update-status-batch', data })
}

// 批量删除横幅
export const deleteBannerBatch = (ids: number[]) => {
  return request.delete({ url: '/reading/admin/banners/delete-batch', data: ids })
}
